package com.szzg10.webservice.chapter2;

import java.util.List;
import java.util.concurrent.ExecutionException;

import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Response;

import com.szzg10.webservice.chapter2.wsimport.GetTeamsResponse;
import com.szzg10.webservice.chapter2.wsimport.Player;
import com.szzg10.webservice.chapter2.wsimport.Team;

public class TeamsHandler implements AsyncHandler<GetTeamsResponse> {

	@Override
	public void handleResponse(Response<GetTeamsResponse> response) {
		
		try {
			GetTeamsResponse getTeamsResponse = response.get();
			List<Team> list = getTeamsResponse.getReturn();
			for(Team element: list) {
				System.out.println(element.getName());
				List<Player> players = element.getPlayers();
				for(Player player: players) {
					System.out.println(player.getName());
				}
				System.out.println();
			}
			
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}

}
